package com.lemon.smartsafetynew.util.common;

import android.util.Log;

import com.lemon.android.http.HttpUtils;
import com.lemon.smartsafety.app.IApplication;
import com.lemon.smartsafety.utils.app.SharedPreferencesServer;

/**
 * Created by Andrew on 2017/9/23.
 */

public class UrlFormatUtils {

    /**
     * 兼容老版本智慧安全服务云多媒体地址信息的转换接口
     * @param url   多媒体地址后缀信息
     * @return      多媒体地址全部信息
     */
    public static String formatFiles(String url) {

        if(url != null) {
            if(url.contains("@@IPEXP_IMP_FILES_WEB") || url.contains("@@ipexp_files_web_upload_folder")) { //适配后台数据中有前缀的多媒体地址信息
                return HttpUtils.formatFilesUrl(url);
            } else if (url.contains("http")) {
                return url;
            } else {
                SharedPreferencesServer sharedPreferencesServer = new SharedPreferencesServer(IApplication.context());
                return sharedPreferencesServer.getFilesUrl() + url.replace("\\", "/");
            }
        } else {
            return "";
        }
    }

}
